const _function = require("../../utils/functionData.js")
Page({
  data: {
    isRefreshing: false,
    isLoading: false,
    hasMore: true,
    page: 1,
    lectureList: [
      // {
      // id: 1,
      // name: "人工智能前沿技术解析",
      // startTime: "2023-10-10 14:00",
      // participants: 156
    // }
  ],
    _UrlGet_: wx.getStorageSync('img_url')
  },
  onLoad(options) {
    this.getBookStudentList()
  },
  // 获取学生预约列表
  getBookStudentList(e) {
    console.log('选择时间', getApp().globalData.userInfo);
    const param = {
      teacherId: getApp().globalData.userInfo.userId
    }
    _function.getBookStudentList(param, this.getBookStudentListBack, this)
  },
  getBookStudentListBack(res) {
    let dataAll = res.data
    let that = this
    if (dataAll.code == 200) {
      console.log('视频列表', dataAll);
      let arr = []
      dataAll.rows.forEach((item, index) => {
        if (item.isAgree ) {
          arr.push(item)
        }
      })
      console.log('arr',arr)
      that.setData({
        lectureList: arr
      })
    }
  },
  onPullDownRefresh() {
    this.setData({ isRefreshing: true });
    setTimeout(() => {
      this.setData({
        lectureList: [...newData],
        isRefreshing: false,
        page: 1
      });
      wx.stopPullDownRefresh();
    }, 1500);
  },

  loadMore() {
    if (!this.data.hasMore || this.data.isLoading) return;

    this.setData({ isLoading: true });
    setTimeout(() => {
      this.setData({
        lectureList: [...this.data.lectureList, ...newData],
        page: this.data.page + 1,
        isLoading: false,
        hasMore: this.data.page < 3
      });
    }, 1000);
  }
});